﻿// Picturez
//
// Copyright © Frank Nagl, 2008-2012
// admin@franknagl.de
// www.franknagl.de
//
namespace Picturez
{
    using System;
    using System.Drawing;
    using System.Windows.Forms;
    using ComponentFactory.Krypton.Toolkit;

    /// <summary> Provides GUI for additional properties for Picturez main form.</summary>
    public partial class AdvancedPropertiesForm : KryptonForm
    {
        /// <summary>The configuration to use. </summary>
        private readonly Configuration config;

        /// <summary>Provides the different languages for the text strings 
        /// of the program.</summary>
        private readonly LanguagesMain language;

        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="AdvancedPropertiesForm"/> class.
        /// </summary>
        /// <param name="location">The location of this form.</param>
        /// <param name="config">The configuration to use.</param>
        /// <param name="language">The language container to use.</param>
        public AdvancedPropertiesForm(
            Point location, Configuration config, LanguagesMain language)
        {
            this.config = config;
            this.language = language;

            InitializeComponent();
            Location = location;
            SetStrings();
            SetValues();
        }

        /// <summary> Sets the language specific string texts of the GUI elements. </summary>
        public void SetStrings()
        {
            Text = language.Text[46];
            ResamplingTabPage.Text = language.Text[48];
            ResizingAlgGroupBox.Text = language.Text[36];
            rdBtnHQ.Text = language.Text[37];
            rdBtnLQ.Text = language.Text[38];
        }

        private void AdvancedPropertiesFormFormClosed(object sender, FormClosedEventArgs e)
        {
            Dispose(true);
        }

        private void BtnOkClick(object sender, EventArgs e)
        {
            Close();
        }

        private void SetValues()
        {
            if (config.HighQuality)
            {
                rdBtnHQ.Checked = true;
            }
            else
            {
                rdBtnLQ.Checked = true;
            }
        }

        private void RdBtnHqCheckedChanged(object sender, EventArgs e)
        {
            if (rdBtnHQ.Checked)
            {
                config.HighQuality = true;
            }

        }

        private void RdBtnLqCheckedChanged(object sender, EventArgs e)
        {
            if (rdBtnLQ.Checked)
            {
                config.HighQuality = false;
            }
        }
    }
}
